<?php include template('header','admin');?>
	<body>
		<div class="fixed-nav layout">
			<ul>
				<li class="first">添加商家</li>
				<li class="spacer-gray"></li>
				<li><a class="current" href="javascript:;">商家列表</a></li>
				<li><a href="<?php echo url('position_index')?>">商家账号</a></li>
			</ul>
			<div class="hr-gray"></div>
		</div>
		<div class="content padding-big have-fixed-nav">
			<form name="form" action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" enctype="multipart/form-data">
			<div class="form-box clearfix">
				<?php echo Form::input('text', 'supplier_name', $supplier_name, '商家名称：', '请输入商家名称（简称 ）', array('datatype' => '*')); ?>
                <?php echo Form::input('text', 'company', $company, '公司名称：', '请输入公司名称（全称 ）', array('datatype' => '*')); ?>
				<?php echo Form::input('select', 'group_id', $group_id, '商家分组', '请选择分组', array('items'=>$group_format['type']), array('datatype' => '*')); ?>
                
                <?php echo Form::input('text', 'contacts', $contacts, '联系人：', '请输入联系人，例如张晓明', array('datatype' => '*')); ?>
                <?php echo Form::input('text', 'mobile', $mobile, '联系手机：', '请输入手机，例如13612345678', array('datatype' => '*')); ?>
                <?php echo Form::input('text', 'phone', $phone, '公司座机：', '请输入座机号码，例如020-88888888', array('datatype' => '*')); ?>
                
                <?php echo Form::input('text', 'recommender', $recommender, '推荐人：', '请输入商家的推荐人，例如张晓明', array('datatype' => '*')); ?>
                
				<div class="form-group">
					<span class="label">商家状态：</span>
					<div class="box">
						<label class="select-wrap">
							<input class="select-btn" type="radio" <?php if($status == 0 || $status == null){?>checked=""<?php }?> value="0" name="status">正常
						</label>
						<label class="select-wrap">
							<input class="select-btn" type="radio" <?php if($status == 1){?>checked=""<?php }?> value="1" name="status">锁定
						</label>
					<br>
					</div>
					<p class="desc">默认为正常，设置商家状态为锁定，商户账号将不可登录使用</p>
				</div>

			<div class="padding">
				<?php if(isset($id)):?>
					<input type="hidden" name="id" value="<?php echo $id?>" />
				<?php endif;?>
				<input type="hidden" name="type" value="" />
				<input type="submit" class="button bg-main" value="保存" />
				<input type="button" class="button margin-left bg-gray" value="返回" />
			</div>
			</form>
		</div>
		<script type="text/javascript">
			$(window).otherEvent();
			var group_json = <?php echo json_encode($group_format)?>;
			//切换效果

			function loadBegin(group_type){
				$('input[name="type"]').val(group_type);
				if(group_type=="0"){
					$(".form-group:eq(4)").show();
					$(".form-group:eq(5)").hide();
				}else{
					$(".form-group:eq(4)").hide();
					$(".form-group:eq(5)").show();
				}
			}
			$(function(){
			     $('.form-group:last-child').addClass('last-group');
                 
				//模拟第一个点击
				if($('input[name="group_id"]').val()=='')$('.listbox-items span:eq(0)').trigger('click');
                
				var group_type = group_json.type[parseInt($("input[name='group_id']").val())];
                
				loadBegin(group_type);
                
				$('input[name="group_id"]').live('change', function() {
					group_type = group_json.type[parseInt($(this).val())];
					loadBegin(group_type);
				}); 
        }); 
		</script>
	</body>
</html>